﻿using AutoMapper;
using Pay.Data;
using Pay.DTO;
using Pay.Core;
using Pay.IService;
using System.Collections.Generic;

namespace Pay.Service.AutoMapper {

    public class GoodDeclarationMapper : IStartupDto {
        private IMapperConfigurationExpression _cfg;
        public GoodDeclarationMapper(IMapperConfigurationExpression cfg) {
            _cfg = cfg;
        }
        public void Execute() {
            Create();
        }
        protected virtual void Create() {

            _cfg.CreateMap<GoodDeclaration, good_declaration_dto>()
                .ForMember(dest => dest.id, src => src.MapFrom(c => c.Id))
                .ForMember(dest => dest.good_sku, src => src.MapFrom(c => c.GoodSKU))
                .ForMember(dest => dest.company_name, src => src.MapFrom(c => c.CompanyName))
                .ForMember(dest => dest.hs_code, src => src.MapFrom(c => c.HSCode))
                .ForMember(dest => dest.good_name, src => src.MapFrom(c => c.GoodName))
                .ForMember(dest => dest.good_description, src => src.MapFrom(c => c.GoodDescription))
                .ForMember(dest => dest.model, src => src.MapFrom(c => c.Model))
                .ForMember(dest => dest.unit, src => src.MapFrom(c => c.Unit))
                .ForMember(dest => dest.min_unit, src => src.MapFrom(c => c.MinUnit))
                .ForMember(dest => dest.ingredient, src => src.MapFrom(c => c.Ingredient))
                .ForMember(dest => dest.barcode, src => src.MapFrom(c => c.Barcode))
                .ForMember(dest => dest.category, src => src.MapFrom(c => c.Category))
                .ForMember(dest => dest.application, src => src.MapFrom(c => c.Application))
                .ForMember(dest => dest.produc_country, src => src.MapFrom(c => c.ProducCountry))
                .ForMember(dest => dest.produc_company, src => src.MapFrom(c => c.ProducCompany))
                .ForMember(dest => dest.brand, src => src.MapFrom(c => c.Brand))
                .ForMember(dest => dest.supplier, src => src.MapFrom(c => c.Supplier))
                .ForMember(dest => dest.audit_status, src => src.MapFrom(c => c.AuditStatus))
                .ForMember(dest => dest.create_time, src => src.MapFrom(c => c.CreateTime.ToDateTime()))
                .ForMember(dest => dest.weight, src => src.MapFrom(c => c.Weight))
                .ForMember(dest => dest.weight_unit, src => src.MapFrom(c => c.WeightUnit))
                .ForMember(dest => dest.tax, src => src.MapFrom(c => c.Tax))
                .ForMember(dest => dest.file_code, src => src.MapFrom(c => c.FileCode))
                .ForMember(dest => dest.merchant_id, src => src.MapFrom(c => c.MerchantId));


            _cfg.CreateMap<good_declaration_dto, GoodDeclaration>()
                .ForMember(dest => dest.Id, src => src.MapFrom(c => c.id))
                .ForMember(dest => dest.GoodSKU, src => src.MapFrom(c => c.good_sku))
                .ForMember(dest => dest.CompanyName, src => src.MapFrom(c => c.company_name))
                .ForMember(dest => dest.HSCode, src => src.MapFrom(c => c.hs_code))
                .ForMember(dest => dest.GoodName, src => src.MapFrom(c => c.good_name))
                .ForMember(dest => dest.GoodDescription, src => src.MapFrom(c => c.good_description))
                .ForMember(dest => dest.Model, src => src.MapFrom(c => c.model))
                .ForMember(dest => dest.Unit, src => src.MapFrom(c => c.unit))
                .ForMember(dest => dest.MinUnit, src => src.MapFrom(c => c.min_unit))
                .ForMember(dest => dest.Ingredient, src => src.MapFrom(c => c.ingredient))
                .ForMember(dest => dest.Barcode, src => src.MapFrom(c => c.barcode))
                .ForMember(dest => dest.Category, src => src.MapFrom(c => c.category))
                .ForMember(dest => dest.Application, src => src.MapFrom(c => c.application))
                .ForMember(dest => dest.ProducCountry, src => src.MapFrom(c => c.produc_country))
                .ForMember(dest => dest.ProducCompany, src => src.MapFrom(c => c.produc_company))
                .ForMember(dest => dest.Brand, src => src.MapFrom(c => c.brand))
                .ForMember(dest => dest.Supplier, src => src.MapFrom(c => c.supplier))
                .ForMember(dest => dest.AuditStatus, src => src.MapFrom(c => c.audit_status))
                .ForMember(dest => dest.CreateTime, src => src.MapFrom(c => c.create_time.ToUnix()))
                .ForMember(dest => dest.Weight, src => src.MapFrom(c => c.weight))
                .ForMember(dest => dest.WeightUnit, src => src.MapFrom(c => c.weight_unit))
                .ForMember(dest => dest.Tax, src => src.MapFrom(c => c.tax))
                .ForMember(dest => dest.FileCode, src => src.MapFrom(c => c.file_code))
                .ForMember(dest => dest.MerchantId, src => src.MapFrom(c => c.merchant_id));
        }
    }
}
